package mahjong;

/**
 * This class is used to format an int into the appropriate
 *String format for time display
 */
public class TimeFormater 
{

	/**
	 * This static method returns a formated time string from an int
	 * @param t int you want to format to time String
	 * @return time String hh:mm:ss corresponding to t
	 */
	public static String formatTime(int t)
	{
		int wTime = t;
		 String out = "";
		 // check hours
		 if(wTime/3600 > 0)
		 {
			 out += String.format("%02d:", wTime/3600);
			 wTime -= ((wTime/3600) *3600);
		 }
		 else
		 {
			 out += "00:";
		 }
		 //check minutes
		 if(wTime/60 > 0)
		 {
			 out += String.format("%02d:", wTime/60);
			 wTime -= ((wTime/60) *60);
		 }
		 else
		 {
			 out += "00:";
		 }
		 //check seconds
		 out += String.format("%02d", wTime);		 
		 return out;
	}
}
